package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.FriendsCategoryDictMapper;
import com.ghck.server.model.FriendsCategoryDict;
import com.ghck.server.model.query.FriendsCategoryDictQuery;
import com.ghck.server.service.FriendsCategoryDictService;

/**
 * 亲友关系字典表  <br>
 * dict_friends_category <br>
 * v1.0 2016-05-08
 */
 @Service
 @Transactional
 public class FriendsCategoryDictServiceImpl implements FriendsCategoryDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(FriendsCategoryDictServiceImpl.class);
	
	@Autowired
	private FriendsCategoryDictMapper friendsCategoryDictMapper;
	
	/**
 	*根据ID删除 亲友关系字典表
 	*/
 	@Override
 	public Integer deleteFriendsCategoryDictById(Integer id){
 		return friendsCategoryDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 亲友关系字典表
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertFriendsCategoryDict(List<? extends FriendsCategoryDict> friendsCategoryDicts){
		Integer count = friendsCategoryDictMapper.batchInsert(friendsCategoryDicts);
		return count;
 	}
 	/**
 	*新增 亲友关系字典表
 	*/
 	@Override
 	@Transactional
 	public Integer insertFriendsCategoryDict(FriendsCategoryDict domain){
		Integer id = friendsCategoryDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 亲友关系字典表
 	*/
 	@Override
 	@Transactional
 	public Integer updateFriendsCategoryDict(FriendsCategoryDict domain){
		Integer count = friendsCategoryDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 亲友关系字典表
 	*/
 	public FriendsCategoryDict findFriendsCategoryDictById(Integer id){
 		FriendsCategoryDict result = friendsCategoryDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 亲友关系字典表
 	*/
	public List<FriendsCategoryDict> findFriendsCategoryDictByQuery(FriendsCategoryDictQuery query){
		query.dealWith();
		List<FriendsCategoryDict> result = friendsCategoryDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendsCategoryDict friendsCategoryDict : result) {
				friendsCategoryDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countFriendsCategoryDictByQuery(FriendsCategoryDictQuery query){
 		query.dealWith();
 		Integer result = friendsCategoryDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<FriendsCategoryDict> findFriendsCategoryDictByIds(List<Integer> ids){
 		List<FriendsCategoryDict> result = friendsCategoryDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendsCategoryDict friendsCategoryDict : result) {
				friendsCategoryDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public FriendsCategoryDict findByName(String name){
		FriendsCategoryDict result = friendsCategoryDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<FriendsCategoryDict> findAll(){
		List<FriendsCategoryDict> result = friendsCategoryDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendsCategoryDict friendsCategoryDict : result) {
				friendsCategoryDict.dealWith();
			}
		}
		return result;
	}
}	